<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-07-13 09:20:15
 * @LastEditors: YuanYu
 * @LastEditTime: 2021-10-27 14:30:31
-->
<template>
  <!-- 头部 -->
  <div class="header">
    <!-- 顶部 -->
    <div class="header_top">
      <div class="wrapper">
        <div class="left">个人博客网</div>
        <div class="right">欢迎</div>
      </div>
    </div>
    <!-- 底部 -->
    <div class="header_bottom">
      <div class="wrapper">
        <div class="logo" @click="toHome()">
          <img src="../../../public/logo_01.png" alt="" />
          <h2 class="home" @click="toHome()">返回首页</h2>
        </div>
        <ul class="menu">
          <li class="menuLi" @click="toList(menuItem)" v-for="menuItem in menuData" :key="menuItem.id">
            {{menuItem.name}}
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import {get} from '../../utils/request'
export default {
  data() {
    return {
      menuData:[]
    }
  },
  methods: {
    getMenuData() {
      get('/index/category/findAll').then(res => {
        // console.log(res);
        this.menuData = res.data;
      })
    },
    toList(menuItem){
      this.$router.push({
        path: '/list',
        query: menuItem
      })
    },
    toHome() {
      this.$router.push('/');
    }
  },
  created() {
    this.getMenuData();
  },
};
</script>

<style lang="scss" scoped>
// 头部样式
.header {
  background-color: #dce0e3;
  // 头部顶部样式
  .header_top {
    background-color: #528c38;
    color: white;
    .wrapper {
      // 左侧样式
      .left {
        float: left;
      }
      // 右侧样式
      .right {
        float: right;
      }
      .left,
      .right {
        line-height: 30px;
      }
    }
    // 清除浮动
    .wrapper::after {
      display: block;
      content: "";
      clear: both;
    }
  }
  // 头部底部样式
  .header_bottom {
    margin-top: 10px;
    .wrapper {
      display: flex;
      justify-content: space-between;
      // 左侧图标
      .logo {
        display: flex;
        flex: 1;
        img {
          width: 200px;
          cursor: pointer;
        }
        .home{
          margin-left: 30px;
          margin-top: 21px;
          cursor: pointer;
        }
        .home:hover{
          color:floralwhite;
        }
      }
      // 右侧菜单
      .menu {
        flex: 2;
        display: flex;
        li,span{
          line-height: 70px;
          font-size: 20px;
          padding: 0 10px;
          cursor: pointer;
          font-weight: bold;
        }
        .menuLi:hover{
          color:floralwhite;
        }
      }
    }
  }
}
</style>